/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * ControlPrenez.java
 *
 * Created on 14-dic-2011, 13:05:34
 */
package formularios;

import Reportes.MetodosImpresion;
import clases.ConversorRSaDefaultTableModel;
import clases.ProcesarTxt;
import clases.abmBovino;
import clases.conexion;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
 *
 * @author Elio
 */
public class ControlPrenez extends javax.swing.JDialog {
    String consultainicial="";
  //  DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
    /** Creates new form ControlPrenez */
    public ControlPrenez(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        this.setTitle("Control de Preñez");
        consultainicial="SELECT c.identificacion, c.fecha, tb.descripcion, c.detalle FROM controles c,"
                + " bovino b ,tipobovino tb where idControl=1 and b.identificacion=c.identificacion and b.idtipobovino=tb.idtipobovino order by c.fecha desc";
        CrearTabla(consultainicial);
        lblCantidad.setText(String.valueOf(tablaPrenez.getRowCount()));
    //    calendarioDesde.setDateFormat(df);
   //     calendarioDesde.repaint();
        
        
       //calendarioDesde.setDateFormat(java.text.DateFormat.);
    }
    
    public void Conectar(){
        try{
            mdbc = new conexion();
            mdbc.init();
            Connection conn= mdbc.getMyConnection();
            stmt = conn.createStatement();
        }catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null, "Problemas al concetarse a la Base de Datos","Error",JOptionPane.ERROR_MESSAGE);
        }
    }
    
     private void CrearTabla(String sql){
      
          try {
            Conectar();
            ResultSet rs = stmt.executeQuery(sql);

      
            tablaPrenez.setModel(modelo);
            tablaPrenez.setAutoResizeMode(tablaPrenez.AUTO_RESIZE_ALL_COLUMNS);
              
                    
            ConversorRSaDefaultTableModel.completar(rs, modelo);

        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, "Error en la consulta de control preñez" + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }
        
    }
    
    private conexion mdbc;
    private Statement stmt;
    private DefaultTableModel modelo = new DefaultTableModel();

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        btnNuevoControlPreñez = new javax.swing.JButton();
        panelConsultas = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaPrenez = new javax.swing.JTable();
        tabPanelBuscarAnimal = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        txtBuscarAnimalPreñez = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        cbEstadoAnimal = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        lblCantidad = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        calendarioDesdePreñez = new org.freixas.jcalendar.JCalendarCombo();
        jLabel4 = new javax.swing.JLabel();
        calendarioHastaPreñez = new org.freixas.jcalendar.JCalendarCombo();
        jLabel5 = new javax.swing.JLabel();
        btnBuscarFechasPreñez = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        cbEstadoAnimal1 = new javax.swing.JComboBox();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        MenuCantidadAnimales = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Control Preñez");

        jPanel1.setLayout(new java.awt.GridLayout(1, 2));

        btnNuevoControlPreñez.setText("Nuevo Control");
        btnNuevoControlPreñez.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNuevoControlPreñezActionPerformed(evt);
            }
        });
        jPanel1.add(btnNuevoControlPreñez);

        tablaPrenez.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane1.setViewportView(tablaPrenez);

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel2.setText("Buscar:");

        txtBuscarAnimalPreñez.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtBuscarAnimalPreñezKeyReleased(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Tahoma", 2, 11));
        jLabel3.setText("(Ingrese el Nº de identificación del animal)");

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel6.setText("Filtro por Estado animal: ");

        cbEstadoAnimal.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "todos", "vacia", "vacia con cría", "preñada grande", "preñada chica" }));
        cbEstadoAnimal.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbEstadoAnimalItemStateChanged(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel8.setText("Cantidad de animles por \"estado\" seleccionado:");

        lblCantidad.setFont(new java.awt.Font("Tahoma", 0, 12));
        lblCantidad.setForeground(new java.awt.Color(255, 0, 0));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(txtBuscarAnimalPreñez, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addComponent(jLabel3))
                        .addGroup(jPanel3Layout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(cbEstadoAnimal, 0, 214, Short.MAX_VALUE)))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(lblCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(177, 177, 177))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtBuscarAnimalPreñez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(cbEstadoAnimal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(lblCantidad, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        tabPanelBuscarAnimal.addTab("Buscar por Animal", jPanel3);

        calendarioDesdePreñez.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "10-03-2012" }));
        calendarioDesdePreñez.setDateFormat(new SimpleDateFormat("dd/MM/yyyy"));

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel4.setText("Desde:");

        calendarioHastaPreñez.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "10-03-2012" }));
        calendarioHastaPreñez.setDateFormat(new SimpleDateFormat("dd/MM/yyyy"));

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 12));
        jLabel5.setText("Hasta:");

        btnBuscarFechasPreñez.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/buscar.png"))); // NOI18N
        btnBuscarFechasPreñez.setText("Buscar");
        btnBuscarFechasPreñez.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBuscarFechasPreñezActionPerformed(evt);
            }
        });

        jLabel7.setText("Filtro por estado animales:");

        cbEstadoAnimal1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "todos", "vacia", "vacia con cría", "preñada grande", "preñada chica" }));
        cbEstadoAnimal1.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbEstadoAnimal1ItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5))
                        .addGap(52, 52, 52)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(calendarioHastaPreñez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(calendarioDesdePreñez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cbEstadoAnimal1, 0, 202, Short.MAX_VALUE)
                        .addGap(93, 93, 93)
                        .addComponent(btnBuscarFechasPreñez)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnBuscarFechasPreñez)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(calendarioDesdePreñez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(calendarioHastaPreñez, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(cbEstadoAnimal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(28, 28, 28))
        );

        tabPanelBuscarAnimal.addTab("Buscar por Fechas", jPanel4);

        javax.swing.GroupLayout panelConsultasLayout = new javax.swing.GroupLayout(panelConsultas);
        panelConsultas.setLayout(panelConsultasLayout);
        panelConsultasLayout.setHorizontalGroup(
            panelConsultasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
            .addGroup(panelConsultasLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(tabPanelBuscarAnimal, javax.swing.GroupLayout.DEFAULT_SIZE, 544, Short.MAX_VALUE)
                .addGap(10, 10, 10))
        );
        panelConsultasLayout.setVerticalGroup(
            panelConsultasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelConsultasLayout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tabPanelBuscarAnimal)
                .addContainerGap())
        );

        jMenu1.setText("Reportes");

        MenuCantidadAnimales.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/form.png"))); // NOI18N
        MenuCantidadAnimales.setText("Cantidad de animales por estado");
        MenuCantidadAnimales.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuCantidadAnimalesActionPerformed(evt);
            }
        });
        jMenu1.add(MenuCantidadAnimales);

        jMenuBar1.add(jMenu1);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 564, Short.MAX_VALUE)
                    .addComponent(panelConsultas, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(panelConsultas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-600)/2, (screenSize.height-489)/2, 600, 489);
    }// </editor-fold>//GEN-END:initComponents

private void btnNuevoControlPreñezActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNuevoControlPreñezActionPerformed
    new ProcesarTxt().LeerControles(1);
    CrearTabla(consultainicial);
}//GEN-LAST:event_btnNuevoControlPreñezActionPerformed





    private void txtBuscarAnimalPreñezKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscarAnimalPreñezKeyReleased

        String consulta = "SELECT c.identificacion, c.fecha, tb.descripcion, "                 + "c.detalle FROM controles c, bovino b ,tipobovino tb where"                 + " idControl=1 and b.identificacion=c.identificacion and"                 + " c.identificacion LIKE '%" + txtBuscarAnimalPreñez.getText() + "%' and b.idtipobovino=tb.idtipobovino "                 + "order by c.fecha desc";          CrearTabla(consulta);     }//GEN-LAST:event_txtBuscarAnimalPreñezKeyReleased

    private void btnBuscarFechasPreñezActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBuscarFechasPreñezActionPerformed
    
        String fechadesde = convertirFecha(calendarioDesdePreñez.getSelectedItem().toString());  
        String fechahasta = convertirFecha(calendarioHastaPreñez.getSelectedItem().toString());  
        String consulta= "SELECT c.identificacion, c.fecha, tb.descripcion, c.detalle FROM controles c, bovino b ,tipobovino tb where idControl=1 and b.identificacion=c.identificacion and "
                + "b.idtipobovino=tb.idtipobovino and c.fecha between '"+fechadesde+"' and '"+fechahasta+"'";
        cbEstadoAnimal1.setSelectedIndex(0);
        CrearTabla(consulta);
    }//GEN-LAST:event_btnBuscarFechasPreñezActionPerformed

    private void cbEstadoAnimal1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEstadoAnimal1ItemStateChanged
        String fechadesde = convertirFecha(calendarioDesdePreñez.getSelectedItem().toString());  
        String fechahasta = convertirFecha(calendarioHastaPreñez.getSelectedItem().toString());  
        String consulta= "SELECT c.identificacion, c.fecha, tb.descripcion, c.detalle FROM controles c, bovino b ,tipobovino tb where idControl=1 and b.identificacion=c.identificacion and "
                + "b.idtipobovino=tb.idtipobovino and c.fecha between '"+fechadesde+"' and '"+fechahasta+"' and c.detalle LIKE '%" + cbEstadoAnimal1.getSelectedItem() + "%'";
        CrearTabla(consulta);
    }//GEN-LAST:event_cbEstadoAnimal1ItemStateChanged

    private void cbEstadoAnimalItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbEstadoAnimalItemStateChanged
     
        String consulta = "";      
        if (cbEstadoAnimal.getSelectedItem().equals("todos")) {
            consulta = "SELECT c.identificacion, c.fecha, tb.descripcion, " 
                    + "c.detalle FROM controles c, bovino b ,tipobovino tb where"
                    
                    + " idControl=1 and b.identificacion=c.identificacion and"
                    + " c.identificacion LIKE '%" + txtBuscarAnimalPreñez.getText() + "%' "
                    + "and b.idtipobovino=tb.idtipobovino order by c.fecha desc";
        } else {             
            consulta = "SELECT c.identificacion, c.fecha, tb.descripcion, "
                    + "c.detalle FROM controles c, bovino b ,tipobovino tb "
                    + "where idControl=1 and b.identificacion=c.identificacion and"
                    + " c.identificacion LIKE '%" + txtBuscarAnimalPreñez.getText() + "%' and"
                    + " b.idtipobovino=tb.idtipobovino and c.detalle='" + cbEstadoAnimal.getSelectedItem() + "' order "
                    + "by c.fecha desc";         
        }         
        CrearTabla(consulta);                                                    
        lblCantidad.setText(String.valueOf(tablaPrenez.getRowCount()));
    }//GEN-LAST:event_cbEstadoAnimalItemStateChanged

    private void MenuCantidadAnimalesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuCantidadAnimalesActionPerformed
        try {
            new MetodosImpresion().ReporteCantidadAnimales();
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(ControlPrenez.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(ControlPrenez.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_MenuCantidadAnimalesActionPerformed

     public String convertirFecha(String FechaA){
      String anio,mes,dia;
     //30112011
      anio=FechaA.substring(6,10);
      mes=FechaA.substring(3,5);
      dia=FechaA.substring(0,2);
      String Fecha=anio+"-"+mes+"-"+dia;
      return Fecha;

    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ControlPrenez.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ControlPrenez.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ControlPrenez.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ControlPrenez.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                ControlPrenez dialog = new ControlPrenez(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
        
        //jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(java.text.DateFormat.getDateInstance(java.text.DateFormat.FULL))));
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem MenuCantidadAnimales;
    private javax.swing.JButton btnBuscarFechasPreñez;
    private javax.swing.JButton btnNuevoControlPreñez;
    private org.freixas.jcalendar.JCalendarCombo calendarioDesdePreñez;
    private org.freixas.jcalendar.JCalendarCombo calendarioHastaPreñez;
    private javax.swing.JComboBox cbEstadoAnimal;
    private javax.swing.JComboBox cbEstadoAnimal1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblCantidad;
    private javax.swing.JPanel panelConsultas;
    private javax.swing.JTabbedPane tabPanelBuscarAnimal;
    private javax.swing.JTable tablaPrenez;
    private javax.swing.JTextField txtBuscarAnimalPreñez;
    // End of variables declaration//GEN-END:variables
}
